home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS05.ADF / IFF / remalloc.h < prev    next >
C/C++ Source or Header  |  1986-04-20  |  3KB  |  87 lines

  1.  
  2. /** RemAlloc.h **********************************************************/
  3. /*  ChipAlloc(), ExtAlloc(), RemAlloc(), RemFree().              */
  4. /*  ALLOCators which REMember the size allocated, for simpler freeing.     */
  5. /*                                                                      */
  6. /* Date      Who Changes                                                */
  7. /* --------- --- -------------------------------------------------------*/
  8. /* 16-Jan-86 sss Created from DPaint/DAlloc.c                           */
  9. /* 22-Jan-86 jhm Include Compiler.h                         */
  10. /* 25-Jan-86 sss Added ChipNoClearAlloc,ExtNoClearAlloc                 */
  11. /*                                                                      */ 
  12. /* By Jerry Morrison and Steve Shaw, Electronic Arts.                   */ 
  13. /* This software is in the public domain.                               */ 
  14. /*                                                                      */ 
  15. /* This version for the Commodore-Amiga computer.                       */
  16. /*                                                                      */ 
  17. /************************************************************************/
  18. #ifndef REM_ALLOC_H
  19. #define REM_ALLOC_H
  20.  
  21. #ifndef COMPILER_H
  22. #include "iff/compiler.h"
  23. #endif
  24.  
  25.  
  26. /* How these allocators work:
  27.  * The allocator procedures get the memory from the system allocator,
  28.  * actually allocating 4 extra bytes. We store the length of the node in
  29.  * the first 4 bytes then return a ptr to the rest of the storage. The
  30.  * deallocator can then find the node size and free it. */
  31.  
  32.  
  33. #ifdef FDwAT
  34.  
  35. /* RemAlloc allocates a node with "size" bytes of user data.
  36.  * Example:
  37.  *   struct BitMap *bm;
  38.  *   bm = (struct BitMap *)RemAlloc( sizeof(struct BitMap), ...flags... );
  39.  */
  40. extern UBYTE *RemAlloc(LONG, LONG);
  41.               /* size, flags */
  42.  
  43. /* ALLOCator that remembers size, allocates in CHIP-accessable memory.
  44.  * Use for all data to be displayed on screen, all sound data, all data to be
  45.  * blitted, disk buffers, or access by any other DMA channel.
  46.  * Does clear memory being allocated.*/    
  47. extern UBYTE *ChipAlloc(LONG);
  48.                /* size */
  49.  
  50. /* ChipAlloc, without clearing memory.  Purpose: speed when allocate
  51.  * large area that will be overwritten anyway.*/
  52. extern UBYTE *ChipNoClearAlloc(LONG);
  53.     
  54. /* ALLOCator that remembers size, allocates in extended memory.
  55.  * Does clear memory being allocated.
  56.  * NOTICE: does NOT declare "MEMF_FAST".  This allows machines
  57.  * lacking extended memory to allocate within chip memory,
  58.  * assuming there is enough memory left.*/    
  59. extern UBYTE *ExtAlloc(LONG);
  60.               /* size */
  61.  
  62. /* ExtAlloc, without clearing memory.  Purpose: speed when allocate
  63.  * large area that will be overwritten anyway.*/
  64. extern UBYTE *ExtNoClearAlloc(LONG);
  65.  
  66.  
  67. /* FREEs either chip or extended memory, if allocated with an allocator
  68.  * which REMembers size allocated.
  69.  * Safe: won't attempt to de-allocate a NULL pointer.
  70.  * Returns NULL so caller can do
  71.  *   p = RemFree(p);
  72.  */
  73. extern UBYTE *RemFree(UBYTE *);
  74.             /*  p  */
  75.  
  76. #else /* not FDwAT */
  77.  
  78. extern UBYTE *RemAlloc();
  79. extern UBYTE *ChipAlloc();
  80. extern UBYTE *ExtAlloc();
  81. extern UBYTE *RemFree();
  82.  
  83. #endif /* FDwAT */
  84.  
  85. #endif REM_ALLOC_H
  86.  
  87.